home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / OLE_Files / Visual_Basic / OLEShellForm.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-03-08  |  5.4 KB  |  161 lines

  1. VERSION 5.00
  2. Begin VB.Form OLEShellForm 
  3.    Caption         =   "OLEShell"
  4.    ClientHeight    =   2220
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4035
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    MinButton       =   0   'False
  11.    ScaleHeight     =   2220
  12.    ScaleWidth      =   4035
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.TextBox YText 
  15.       Height          =   315
  16.       Left            =   540
  17.       TabIndex        =   4
  18.       Text            =   "0"
  19.       Top             =   1740
  20.       Width           =   975
  21.    End
  22.    Begin VB.TextBox XText 
  23.       Height          =   315
  24.       Left            =   540
  25.       TabIndex        =   3
  26.       Text            =   "0"
  27.       Top             =   1200
  28.       Width           =   975
  29.    End
  30.    Begin VB.CommandButton OKButton 
  31.       Caption         =   "OK"
  32.       Height          =   375
  33.       Left            =   2820
  34.       TabIndex        =   2
  35.       Top             =   120
  36.       Width           =   1095
  37.    End
  38.    Begin VB.CommandButton ComputeOutputButton 
  39.       Caption         =   "Compute Output"
  40.       Enabled         =   0   'False
  41.       Height          =   375
  42.       Left            =   120
  43.       TabIndex        =   1
  44.       Top             =   600
  45.       Width           =   1455
  46.    End
  47.    Begin VB.CommandButton OpenBreadboardButton 
  48.       Caption         =   "Open Breadboard"
  49.       Height          =   375
  50.       Left            =   120
  51.       TabIndex        =   0
  52.       Top             =   120
  53.       Width           =   1455
  54.    End
  55.    Begin VB.Label ZOutputLabel 
  56.       Height          =   315
  57.       Left            =   2160
  58.       TabIndex        =   8
  59.       Top             =   1500
  60.       Width           =   1095
  61.    End
  62.    Begin VB.Label ZLabel 
  63.       Caption         =   "Z:"
  64.       Height          =   255
  65.       Left            =   1800
  66.       TabIndex        =   7
  67.       Top             =   1500
  68.       Width           =   255
  69.    End
  70.    Begin VB.Label YLabel 
  71.       Caption         =   "Y:"
  72.       Height          =   255
  73.       Left            =   180
  74.       TabIndex        =   6
  75.       Top             =   1800
  76.       Width           =   255
  77.    End
  78.    Begin VB.Label XLabel 
  79.       Caption         =   "X:"
  80.       Height          =   255
  81.       Left            =   180
  82.       TabIndex        =   5
  83.       Top             =   1260
  84.       Width           =   255
  85.    End
  86. Attribute VB_Name = "OLEShellForm"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = False
  89. Attribute VB_PredeclaredId = True
  90. Attribute VB_Exposed = False
  91. Dim NSApp As Object
  92. Dim NSBB As Object
  93. Private Sub ComputeOutputButton_Click()
  94.     'Ensure that X and Y contain numerical values
  95.     If (Not IsNumeric(XText.Text)) Or (Not IsNumeric(YText.Text)) Then
  96.         MsgBox "X and Y must contain numerical values.", vbOKOnly + vbInformation
  97.         Exit Sub
  98.     End If
  99.     'Read X and Y input data from text boxes and prepare for sending to the
  100.     'OLE Input component on the example NeuroSolutions breadboard
  101.     Dim xInput As Single
  102.     xInput = CSng(XText.Text)
  103.     Dim yInput As Single
  104.     yInput = CSng(YText.Text)
  105.     Dim inputData(0 To 1, 0 To 0) As Variant
  106.     inputData(0, 0) = xInput
  107.     inputData(1, 0) = yInput
  108.     Dim inputDataWrapped As Variant
  109.     inputDataWrapped = inputData
  110.     'Send input data to the OLE Input component
  111.     NSBB.sendDataToEngine inputDataWrapped, "oLEInput"
  112.     'Resets epoch counter but doesn't reset weight because learning is turned off
  113.     NSBB.send "control.resetNetwork()"
  114.     'Calculates network output for the given input
  115.     NSBB.send "control.stepExemplar()"
  116.     'Get the network output and write it to Z
  117.     Dim outputData As Variant
  118.     outputData = NSBB.send("matrixViewer.getProbeData()")
  119.     '"getProbeData" will fail if running in evaluation mode
  120.     On Error Resume Next
  121.     ZOutputLabel.Caption = Format(outputData(0, 0), "0.0000")
  122.     On Error GoTo 0
  123. End Sub
  124. Private Sub Form_Unload(Cancel As Integer)
  125. '    NSApp.closeApplication
  126.     Set NSBB = Nothing
  127.     Set NSApp = Nothing
  128. End Sub
  129. Private Sub OKButton_Click()
  130.     Unload Me
  131. End Sub
  132. Private Sub OpenBreadboardButton_Click()
  133.     'Open NeuroSolutions and maximize it
  134.     Set NSApp = CreateObject("NeuroSolutions.Application")
  135.     NSApp.maximize
  136.     'Determine the full path of the example NeuroSolutions breadboard
  137.     Dim breadboardPathName As String
  138.     breadboardPathName = NSApp.pathFromNS("OLE\Breadboard\MLPXor.nsb")
  139.     If checkIfFileExists(breadboardPathName) = False Then
  140.         breadboardPathName = App.Path & "\..\Breadboard\MLPXor.nsb"
  141.         If checkIfFileExists(breadboardPathName) = False Then
  142.             MsgBox "The breadboard for this example could not be found.", vbCritical + vbOKOnly
  143.             Set NSApp = Nothing
  144.             Exit Sub
  145.         End If
  146.     End If
  147.     'Open the example NeuroSolutions breadboard
  148.     NSApp.openBreadboard breadboardPathName
  149.     Set NSBB = NSApp.activeBreadboard
  150.     NSBB.maximize
  151.     'Enable Compute Output button since breadboard was opened successfully
  152.     ComputeOutputButton.Enabled = True
  153. End Sub
  154. Function checkIfFileExists(filePathName As String) As Boolean
  155.     If (filePathName = "") Or (Dir(filePathName) = "") Then
  156.         checkIfFileExists = False
  157.     Else
  158.         checkIfFileExists = True
  159.     End If
  160. End Function
  161.